

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;

public class ChatTemplate extends javax.swing.JFrame {
    private JTextArea outputTextArea;

    private JLabel textMessageLabel;

    private AbstractAction quitButtonAction;

    private JComboBox usersComboBox;

    private JButton quitButton;

    private JLabel usersLabel;

    private JTextField messageTextField;

    private JTextArea connectionTextArea;

    private JPanel southPanel;

    /**
     * Auto-generated main method to display this JFrame
     */
    public static void main(String[] args)
    {
        SwingUtilities.invokeLater(new Runnable() {
            public void run()
            {
                ChatTemplate inst = new ChatTemplate();
                inst.setLocationRelativeTo(null);
                inst.setVisible(true);
            }
        });
    }

    public ChatTemplate() {
        super();
        initGUI();
    }

    private void initGUI()
    {
        try {
            setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            BorderLayout thisLayout = new BorderLayout();
            this.setTitle("Our Chat Application");
            getContentPane().setLayout(thisLayout);

            //Dialog box to obtain the user name
            String userName = JOptionPane.showInputDialog(null,
                    "Enter your User Name : ", "Input Box", 1);

            //Dialog box to obtain the user's ip address
            String ipAdd = JOptionPane.showInputDialog(null,
                    "Enter your IP Address : ", "Input Box", 1);

            //Dialog box to obtain the user's port number
            String pNumber = JOptionPane.showInputDialog(null,
                    "Enter your port number : ", "Input Box", 1);
            {
                outputTextArea = new JTextArea();
                getContentPane().add(outputTextArea, BorderLayout.WEST);
                outputTextArea.setText("chat text");
                outputTextArea.setEditable(false);
                outputTextArea
                        .setPreferredSize(new java.awt.Dimension(331, 473));
                outputTextArea.setBorder(new LineBorder(new java.awt.Color(0,
                        0, 0), 1, false));
            }
            {
                connectionTextArea = new JTextArea();
                getContentPane().add(connectionTextArea, BorderLayout.EAST);
                connectionTextArea.setText("who's on?");
                connectionTextArea.setEditable(false);
                connectionTextArea.setPreferredSize(new java.awt.Dimension(160,
                        473));
                connectionTextArea.setBorder(new LineBorder(new java.awt.Color(
                        0, 0, 0), 1, false));
            }
            {
                southPanel = new JPanel();
                getContentPane().add(southPanel, BorderLayout.SOUTH);
                textMessageLabel = new JLabel();
                textMessageLabel.setText("MSG:");
                textMessageLabel
                        .setPreferredSize(new java.awt.Dimension(29, 14));
                southPanel.add(textMessageLabel);
            }
            {
                messageTextField = new JTextField();
                messageTextField.setText("Enter message text here");
                messageTextField.setPreferredSize(new java.awt.Dimension(148,
                        21));
                southPanel.add(messageTextField);
            }
            {
                usersLabel = new JLabel();
                //getContentPane().add(usersLabel, BorderLayout.CENTER);
                usersLabel.setText("Users:");
                southPanel.add(usersLabel);
            }
            {
                //Make sure you code for the selection of 1 user or all users
                ComboBoxModel usersComboBoxModel = new DefaultComboBoxModel(
                        new String[] { "User One", "User Two" });
                usersComboBox = new JComboBox();
                southPanel.add(usersComboBox);
                usersComboBox.setModel(usersComboBoxModel);
            }
            {
                quitButton = new JButton();
                southPanel.add(quitButton);
                quitButton.setText("Quit");
            }

            pack();
            setSize(500, 500);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Performs the action when the quit button is pressed
     * 
     * @return AbstractionAction object
     */
    private AbstractAction getQuitButtonAction()
    {
        if (quitButtonAction == null) {
            quitButtonAction = new AbstractAction("quitButtonAction", null) {
                public void actionPerformed(ActionEvent evt)
                {
                }
            };
        }
        return quitButtonAction;
    }

}

